<?php
/*
 * 用户注册
 * 
 */
include '../service/UserService.class.php';
include '../util/class.mailhelper.php';
include '../util/class.tools.php';
include '../util/class.log.php';
header("Content-type:text/html;charset=utf-8");

$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];

/*$username = $_GET['username'];
$password = $_GET['password'];
$email = $_GET['email'];*/


$tools = new tools();
$code = $tools->getValidationCode();  //获得验证码
$userservice = new UserService();
$result = $userservice->regist($username, $password, $email,$code);
if($result == 0)
{
	$array = array('tip' => 0);   //注册失败
	print_r(json_encode($array));
}else
{
	$L = log::get_instance();
	$L->log(0,'用户'.$username.'注册', date('Y-n-j H:m:s'));
	$L->close();
	$array = array('tip' => 1);  //注册成功
	$sendMail = new mailhelper();
	$retult = $sendMail->sendMail($username, $email,$code);
		if($result == 1)
	print_r(json_encode($array));
}

?>
